package Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.CountTodayInDao;

public class TestAjax extends HttpServlet {
	private CountTodayInDao cid = new CountTodayInDao();
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String begin_time =  request.getParameter("begin_time");
		String end_time = request.getParameter("end_time");
		begin_time += " 00:00:00";
		end_time += " 23:59:59";
		double sum_pay = cid.Sum_PayTotal_Time(begin_time, end_time);
		double sum_refund = cid.Sum_RefundTotal_Time(begin_time, end_time);
		int count_pay = cid.Count_PayTotal_Time(begin_time, end_time);
		int count_refund = cid.Count_RefundTotal_Time(begin_time, end_time);
		
		int pay_first_num = cid.Sel_Pay_OneDay_First_Num(begin_time, end_time);
		int pay_end_num = cid.Sel_Pay_OneDay_End_Num(begin_time, end_time);
		int refund_first_num = cid.Sel_Refund_OneDay_First_Num(begin_time, end_time);
		int refund_end_num = cid.Sel_Refund_OneDay_End_Num(begin_time, end_time);
		PrintWriter out = response.getWriter();
		out.write(sum_pay+","+sum_refund+","+count_pay+","+count_refund+","+pay_first_num+","+pay_end_num+","+refund_first_num+","+refund_end_num);
		out.flush();
		out.close();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}
}
